package com.stress.testing.common;

import com.alibaba.ttl.TransmittableThreadLocal;

public class TraceContextHolder {
    private static final TransmittableThreadLocal<TraceContext> TRACE_CONTEXT_THREAD_LOCAL =
            new TransmittableThreadLocal<>();

    public static TraceContext getTraceContext() {
        return TRACE_CONTEXT_THREAD_LOCAL.get();
    }

    public static void setTraceContext(TraceContext traceContext) {
        TRACE_CONTEXT_THREAD_LOCAL.set(traceContext);
    }

    public static TraceContext removeTraceContext() {
        TraceContext traceContext = TRACE_CONTEXT_THREAD_LOCAL.get();
        TRACE_CONTEXT_THREAD_LOCAL.remove();
        return traceContext;
    }
}
